﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<TanHungViet.Web.Models.Product>" %>
<%@ Import Namespace="TanHungViet.Helper"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Thêm Sửa Sản Phẩm - PHẦN MỀM XÂY DỰNG – TÂN HƯNG VIỆT – 0835.125.795
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="CssJsRef" runat="server">
    <link rel="stylesheet" type="text/css" href='<%= Url.Content("~/Content/css/jquery-ui-1.8.16.custom.css")%>' /> 
    
    <script type='text/javascript' language='javascript' src='<%= Url.Content("~/ckeditor/ckeditor.js") %>'></script>
    <script type='text/javascript' language='javascript' src='<%= Url.Content("~/Scripts/jquery-ui-1.8.16.custom.min.js") %>'></script>
    
    <script type="text/javascript">
        $(function() {
            //            $("#tabs").tabs({ fx: [{ opacity: 'toggle', duration: 'normal' },   // hide option
            //                            {opacity: 'toggle', duration: 'fast'}]
            //            });

            $("#UpdateDate").datepicker({ dateFormat: 'dd/mm/yy' });
            $(".numeric").forceNumeric();
        });

        function Cancel() {
            window.location = '/QuanLyNoiDung';
        }

        $.fn.forceNumeric = function() {
            return this.each(function() {
            $(this).keydown(function(e) {
                    var key = e.which || e.keyCode;

                    if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
                    // numbers   
                         key >= 48 && key <= 57 ||
                    // Numeric keypad
                         key >= 96 && key <= 105 ||
                    // comma, period and minus, . on keypad
                        key == 190 || key == 188 || key == 109 || key == 110 ||
                    // Backspace and Tab and Enter
                        key == 8 || key == 9 || key == 13 ||
                    // Home and End
                        key == 35 || key == 36 ||
                    // left and right arrows
                        key == 37 || key == 39 ||
                    // Del and Ins
                        key == 46 || key == 45)
                        return true;

                    return false;
                });
            });
        }

        function Validate() {
            // validate name
            var errorName = false;
            var errorNameMsg = "";
            var name = $("#ProductName").val();
            if (name == '') {
                errorNameMsg = "Tên sản phẩm không được bỏ trống!";
                errorName = true;
            }

            if (errorName == true) {
                $("#error-name").html(errorNameMsg);
                return false;
            }
            else {
                $("#error-name").html('');
                return true;
            }
        }

        function Submit() {
            if (Validate())
                document.forms[0].submit();
        }
	    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="title-mainright1">
	    <h2 class="text1"><%= ViewData["ProductName"]%></h2>
    </div>
    
    <% Html.EnableClientValidation(); %> 
    <% using (Html.BeginForm("ThemSuaSanPham", "QuanLyNoiDung", FormMethod.Post, new { id = "form-news", enctype = "multipart/form-data" }))
       {%>
	<div class="content1">
		<div class="top-box2"><img src='<%=Url.Content("~/Content/images/top-box21.jpg")%>'/> </div>		
			<div class="center-box21">
			  <div style="margin-left:50px;">
                    <label><span style="color:Orange;"><b>Hình đại diện</b></span></label>
	                <br />
	                <table>
	                    <tr>
	                        <td><img src="<%= Url.Content(Constant.ImageProductPath + Model.ProductImage ?? string.Empty) %>" alt="" width="150px" height="100px"/></td>
	                        <td><input id="file" type="file" name="file" /></td>
	                    </tr>
	                </table> 
                    
	                <p>
	                    <label><span style="color:Orange;"><b>Tên sản phẩm</b></span></label>
	                    <br />
	                    <%= Html.TextBoxFor(b => b.ProductName, new { size = "100" })%>
	                    <span id="error-name" style="color:#FF0000"></span>
	                </p>
	                
	                <p>
	                    <label><span style="color:Orange;"><b>Phiên bản</b></span></label>
	                    <br />
	                    <%= Html.TextBoxFor(b => b.ProductVersion, new { size = "100" })%>
	                </p>
	                
	                <p>
	                    <label><span style="color:Orange;"><b>Giá tiền</b></span></label>
	                    <br />
	                    <%= Html.TextBoxFor(b => b.ProductPrice, new { size = "100", @class = "numeric" })%>
	                </p>
	                
	                <p>
	                    <label><span style="color:Orange;"><b>Ngày cập nhật</b></label>
	                    <br />
	                    <% DateTime updateDate = Model.UpdateDate ?? DateTime.Now;%>
	                    <%= Html.TextBox("UpdateDate", updateDate.ToString("dd/MM/yyyy"),
                            new { size = "100", maxlength = "50" })%>
	                </p>
	                
	                <p>
	                    <label><span style="color:Orange;"><b>Link Download</b></span></label>
	                    <br />
	                    <%= Html.TextBoxFor(b => b.DownloadLink, new { size = "100" })%>
	                </p>
	                
	                <p>
	                    <label><span style="color:Orange;"><b>Tính năng cơ bản</b></span></label>
	                    <br />
	                    <%= Html.TextAreaFor(b => b.ProductDescrip, new { rows = "5", cols = "99" })%>
	                </p>
	                
	                <p>
	                    <label><span style="color:Orange;"><b>Hiển thị ra trang chủ</b></span></label>
	                    <br />
	                    <% bool inHomePage = Model.InHomePage ?? false;%>
	                    <%= Html.CheckBox("InHomePage", inHomePage) %>
	                </p>
	                
                    <label><span style="color:Orange;"><b>Chi tiết sản phẩm</b></span></label>
                    <br />
                    <br />
                    <%= Html.TextArea("ProductDetail") %>
                    <span id="error-content" style="color:#FF0000"></span>
                    <script type="text/javascript">
                        CKEDITOR.replace('ProductDetail',
                        {
                            width: 800,
                            height: 500,
                            toolbarCanCollapse: false,
                            removePlugins: 'elementspath',
                            uiColor: '#DCDCDC',
                            filebrowserImageBrowseUrl: '/ckeditor/ImageBrowser.aspx?ImageFolderRoot=~/Content/images_product_detail/'
                        });
                    </script>
	                <br />
                    <input type="button" class="button" value="Lưu lại" onclick="Submit()" /> &nbsp;&nbsp;&nbsp;
                    <input type="button" class="button" value="Hủy bỏ" onclick="Cancel()" />
	               </div> 
			</div>            	
		<div class="bottom-box2"><img src='<%=Url.Content("~/Content/images/bottom-box21.jpg")%>'	></div>
	</div> 
	
	<%= Html.HiddenFor(b=>b.ProductID) %>
    <input type="hidden" name="content-type" id="content-type" value="<%= ViewData["ContentType"] %>" />
    <%} %>
</asp:Content>



